/*
 * Offical Website:http://www.mob.com
 * Support QQ: 4006852216
 * Offical Wechat Account:ShareSDK   (We will inform you our updated news at the first time by Wechat, if we release a new version. If you get any problem, you can also contact us with Wechat, we will reply you within 24 hours.)
 *
 * Copyright (c) 2013 mob.com. All rights reserved.
 */

package com.espressif.iot.wxapi;

import android.content.Intent;
import android.widget.Toast;
import cn.sharesdk.wechat.utils.WXAppExtendObject;
import cn.sharesdk.wechat.utils.WXMediaMessage;
import cn.sharesdk.wechat.utils.WechatHandlerActivity;

/** Callback activity demo of Wechat */
public class WXEntryActivity extends WechatHandlerActivity
{

    /**
     * Handling message which sent from wechat
     * <p>
     * This message will be sent from wechat by clicking the app icon at the bottom of the chatting page
     */
    public void onGetMessageFromWXReq(WXMediaMessage msg)
    {
        Intent iLaunchMyself = getPackageManager().getLaunchIntentForPackage(getPackageName());
        startActivity(iLaunchMyself);
    }

    /**
     * Handling message which sent from wechat
     * <p>
     * This message will be sent from wechat by chlicking this app-type message in the chatting list
     */
    public void onShowMessageFromWXReq(WXMediaMessage msg)
    {
        if (msg != null && msg.mediaObject != null && (msg.mediaObject instanceof WXAppExtendObject))
        {
            WXAppExtendObject obj = (WXAppExtendObject)msg.mediaObject;
            Toast.makeText(this, obj.extInfo, Toast.LENGTH_SHORT).show();
        }
    }

}
